<template>
    <div class="wrapper">
        <div class="box-wrapper">
            <div class="box"></div>
        </div>
        <div>
            <el-button @click="loginPost" :loading="loading">登录</el-button>
            <el-button @click="get">get请求</el-button>
        </div>
    </div>
</template>

<script>

export default {
    data() {
        return {
            loading: false
        };
    },
    methods: {
        loginPost() {
            this.$axios.post('user/login', { mobile: '19138288317', pwd: '123456' }).then((res) => {
                this.loading = false;
                localStorage.setItem('TOKEN', res.data.token);
                this.$router.replace({
                    name: 'Home'
                });
            })
            .catch((e) => {
                const errorMsg = e.data ? e.data.msg : '服务器发生错误,请稍后再试';
                console.log(errorMsg)
                this.loading = false;
            });
        },
        get() {
            this.$axios.get('admin/permision').then((res) => {
                console.log(res.data.rbac_item_routes);
            });
        }
    }
};
</script>

<style lang="scss" scoped>
@import 'index.scss';
</style>
